USE [pos]
GO

/****** Object:  Trigger [trg_Roles_U_UpdateUpdateDate]    Script Date: 03/07/2012 23:27:35 ******/
IF  EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[trg_Roles_U_UpdateUpdateDate]'))
DROP TRIGGER [dbo].[trg_Roles_U_UpdateUpdateDate]
GO

USE [pos]
GO

/****** Object:  Trigger [dbo].[trg_Roles_U_UpdateUpdateDate]    Script Date: 03/07/2012 23:27:35 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		Jonathan Loe
-- Create date: 06 Mar 2012
-- Description:	Automatically update UpdateOn column on every update
-- =============================================
CREATE TRIGGER [dbo].[trg_Roles_U_UpdateUpdateDate] 
   ON  [dbo].[Roles] 
   AFTER UPDATE
AS 
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for trigger here
    UPDATE dbo.Roles
    SET    dbo.Roles.UpdateDate = GETDATE()
    FROM   inserted
    WHERE  dbo.Roles.Id = inserted.Id
END

GO


